﻿
//
//  LiveClientConnection.h
//  websocketserver
//  切勿外传，自己使用，完善bug，反馈给作者
//  Created by cl.zhan on 17/5/26.
//  email:zhanchonglongba@126.com/690759587
//
//


#ifndef HTTPCLIENTCONNECTTION_H_H_
#define HTTPCLIENTCONNECTTION_H_H_


#include <QObject>
#include <QtNetwork>
#include <QWebSocket>

#include "websocket/websocketmanager.h"
#include "JsonRpc/CmdRouter.h"


class HttpClientConnection : public QObject {
    Q_OBJECT
public:
    HttpClientConnection(QWebSocket* socket, WebSocketManager* manager,LiveManager * _live_manager, QObject *parent=0);
    ~HttpClientConnection();

    int Init();

    int sendJson(QString str);
    int SendCmd(QString strCmd,QString strParams);

    QHostAddress get_client_address();

    int  DoStartPullStream(QString & pull_url, int num);
    int  DoStopPullStream(QString & pull_url);

signals:
    void disconnected();


private slots:
    void processTextMessage(QString message);
    void processBinaryMessage(QByteArray message);


private:

    CmdRouter    * m_pCmdRouter;
    QWebSocket* _socket;
    WebSocketManager * _manager;
    LiveManager * one_live_manager;

    QHostAddress client_address;

};

#endif // HTTPCLIENTCONNECTTION_H_H_
